from sanic import Sanic
from sanic.response import json

app = Sanic()

@app.route('/')
async def test(request):
    # json函数返回JSON数据,并在响应头中添加Content-Type: application/json
    # ensure_ascii设置为False，使得可以输出UTF-8编码字符
    return json({'name': '小红'}, ensure_ascii=False)

if __name__ == '__main__':
    app.run()
